﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace HamcoWcs.DAL.Migrations
{
    public partial class A21 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<string>(
                name: "TransactionId",
                table: "main_task_bak",
                type: "varchar(50)",
                maxLength: 50,
                nullable: true,
                comment: "MES下发任务是的TransactionId",
                oldClrType: typeof(string),
                oldType: "varchar(20)",
                oldMaxLength: 20,
                oldNullable: true,
                oldComment: "MES下发任务是的TransactionId")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "TransactionId",
                table: "main_task",
                type: "varchar(50)",
                maxLength: 50,
                nullable: true,
                comment: "MES下发任务是的TransactionId",
                oldClrType: typeof(string),
                oldType: "varchar(20)",
                oldMaxLength: 20,
                oldNullable: true,
                oldComment: "MES下发任务是的TransactionId")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "global_config",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false, comment: "主键Id")
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "配置名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Offset = table.Column<int>(type: "int", nullable: false, comment: "偏移量"),
                    Length = table.Column<int>(type: "int", nullable: false, defaultValue: 1, comment: "长度"),
                    Type = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "类型")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Options = table.Column<string>(type: "text", maxLength: 100, nullable: true, comment: "选项")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_global_config", x => x.Id);
                },
                comment: "PLC全局配置表")
                .Annotation("MySql:CharSet", "utf8mb4");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "global_config");

            migrationBuilder.AlterColumn<string>(
                name: "TransactionId",
                table: "main_task_bak",
                type: "varchar(20)",
                maxLength: 20,
                nullable: true,
                comment: "MES下发任务是的TransactionId",
                oldClrType: typeof(string),
                oldType: "varchar(50)",
                oldMaxLength: 50,
                oldNullable: true,
                oldComment: "MES下发任务是的TransactionId")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "TransactionId",
                table: "main_task",
                type: "varchar(20)",
                maxLength: 20,
                nullable: true,
                comment: "MES下发任务是的TransactionId",
                oldClrType: typeof(string),
                oldType: "varchar(50)",
                oldMaxLength: 50,
                oldNullable: true,
                oldComment: "MES下发任务是的TransactionId")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }
    }
}
